package com.beautiful.xin.sort;

import java.util.Arrays;

/**
 * @author xuqingxin 2021/10/9 3:58 下午
 */
public class StringArr {
    public static void main(String[] args) {
        String s = "asdfghjkl";
        int len = 2;
        String[] split = split(s, len);
        System.out.println(Arrays.toString(split));
    }

    public static String[] split(String str, int len) {
        String[] temp = new String[(str.length() / len) + 1];
        for (int i = 0; i < temp.length; i++) {
            if (i == temp.length - 1) {
                temp[i] = str.substring(i * len);
            } else {
                temp[i] = str.substring(i * len, (i * len) + len);
            }
        }
        return temp;
    }
}
